package com.acme;


public class Test {
	public static void main(String[] args) {
		int v1 = 3;
		byte v2 = (byte)v1;   //explicit type cast
		System.out.println(v2);
		v1 = 256;
		byte v3 = (byte)v1;   //explicit type cast; overflow!
		System.out.println(v3); 
		int v4 = 's';
		System.out.println(v4);
		
		byte v5 = 115;
		if (v5 == 's') {	//automatic type cast byte-int-char
			System.out.println("Equals");
		}
		
		//TODO: What exactly will be printed? - ANSWER: 4.0 
		System.out.println((double)4);
		
		//TODO: What exactly will be printed? - ANSWER: 6.0 (automatic type cast int-double)
		double d = 5;
		System.out.println(d + 1);
		
		//boolean b = v4; //this line will cause error anyway, there is no type cast between the boolean type and the int type
		
		//short v6 = "short"; //this line will cause error anyway, there is no type cast between the short type and the String literal
		
		float v7 = 3.67f;
		
		float v9 = 3;//TODO: Why there is no compilation error? - ANSWER: because float is wider than int, automatic type cast int-float is allowed
		
		int v8 = (int)v7; //a part of the number after floating point will be lost
		
		int array[] = new int[27];      //one can modify the array declaration and initialization like this, using the explicit type cast
		double tmp[] = new double[27];
		for (int i =0; i < 27; i++) {
			array[i] = (int)tmp[i];		//explicit type cast; a part of each number after floating point will be lost, if tmp is not initialized by integers
		}
	}
}
